// 题意： 求一个满足Dirac定理的简单图的hamilton回路
//
// 题解：https://en.wikipedia.org/wiki/Ore%27s_theorem
// 		 可以运用，这个定理证明的构造方法。Palmer给出了一个algorithm.
// 		 复杂度O(n^2)。
//
#include <algorithm>
#include <deque>
#include <cstdio>

int const maxn = 1007;
bool map[maxn][maxn];
int n;

typedef std::deque<int> data_type;
data_type hamilton_circle;

/*
void reverse(int l, int r, data_type & a) // l, r both closed. reverse in a circle.
{
	int n = a.size();
	int len = (r + n - l) % n + 1;
	for (int count = 0, i = l; count < len/2; count++, i = (i + 1) % n)
		std::swap(a[i], a[(r + n - count) % n]);
}
*/

void reverse(int l, int r, data_type & a) // l, r both closed. reverse in a circle.
{
	int n = a.size();
	if (l > r) {
		int len = n - (l - r - 1);
		std::rotate(a.begin(), a.begin() + l, a.end());
		std::reverse(a.begin(), a.begin() + len);
		std::rotate(a.rbegin(), a.rbegin() + l, a.rend());
	} else
		std::reverse(a.begin() + l, a.begin() + r + 1);
}

int main()
{
	std::scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		for (int x; std::scanf("%d", &x); ) {
			map[i][x] = map[x][i] = true;
			x = std::getchar();
			if (x == '\n' || x == '\r' || x == EOF) break;
		}

	hamilton_circle.resize(n);
	for (int i = 0; i < n; i++) hamilton_circle[i] = i+1;

	// Palmer algorithm meeting Ore's condition
	for (int time = 0, i, u, v; time < n; time++) {
		for (i = 0; i <= n-1; i++) {
			u = hamilton_circle[i]; v = hamilton_circle[(i + 1) % n];
			if (!map[u][v]) break;
		}
		if (i == n) break;
		for (int j = i + 2; j != (i-1 + n) % n; j = (j + 1) % n) {
			int u1 = hamilton_circle[j % n], v1 = hamilton_circle[(j+1) % n];
			if (!(map[u][u1] && map[v1][v])) continue;
			reverse((i+1) % n, j % n, hamilton_circle);
			break;
		}
	}

	for (int i = 0; i < n; i++)
		if (hamilton_circle[i] == 1) {
			data_type & a = hamilton_circle;
			std::rotate(a.begin(), a.begin() + i, a.end());
			break;
		}

	for (int i = 0; i < n; i++) std::printf("%d ", hamilton_circle[i]);
	std::printf("1\n");
}

